package service

import (
	"guliedu/model"
	"guliedu/repository"
)

type IEduChapterService interface {
	Insert(chapter *model.EduChapter) error
	Update(chapter *model.EduChapter) error
	DeleteByCourseID(id string) error
	GetAllChapterVideo(courseID string) ([]model.EduChapter, error)
	Select(id string) (*model.EduChapter, error)
	Delete(id string) error
}

func NewIEduChapterService() IEduChapterService {
	return &EduChapterService{EduChapterRepository: repository.NewIEduChapterRepository()}
}

type EduChapterService struct {
	EduChapterRepository repository.IEduChapterRepository
}

func (t *EduChapterService) Insert(chapter *model.EduChapter) error {
	return t.EduChapterRepository.Insert(chapter)
}

func (t *EduChapterService) Update(chapter *model.EduChapter) error {
	return t.EduChapterRepository.Update(chapter)
}

func (t *EduChapterService) DeleteByCourseID(id string) error {
	return t.EduChapterRepository.DeleteByCourseID(id)
}

func (t *EduChapterService) GetAllChapterVideo(courseID string) ([]model.EduChapter, error) {
	return t.EduChapterRepository.GetAllChapterVideo(courseID)
}

func (t *EduChapterService) Select(id string) (*model.EduChapter, error) {
	return t.EduChapterRepository.Select(id)
}

func (t *EduChapterService) Delete(id string) error {
	return t.EduChapterRepository.Delete(id)
}
